#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    bool lemonadeChange(vector<int>& bills) {
        int f = 0, t = 0;
        for (auto e : bills) {
            if (e == 5) {
                f++;
            }
            else if (e == 10) {
                if (f == 0)
                    return false;
                else
                    f--, t++;
            }
            else {
                if (f && t)
                    f--, t--;
                else if (f >= 3)
                    f -= 3;
                else
                    return false;
            }
        }
        return true;
    }
};